package com.skywolf.chem.customer.service.impl;

import com.skywolf.chem.common.sysconfig.pojo.vo.PageVO;
import com.skywolf.chem.customer.entity.Signup;
import com.skywolf.chem.customer.mapper.SignupMapper;
import com.skywolf.chem.customer.param.CourseQueryParam;
import com.skywolf.chem.customer.service.ISignupService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.skywolf.chem.live.param.CourseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 课程报名表 服务实现类
 * </p>
 *
 * @author 
 * @since 2020-11-29
 */
@Service
public class SignupServiceImpl extends ServiceImpl<SignupMapper, Signup> implements ISignupService {

    @Autowired
    SignupMapper signupMapper;

    @Override
    public PageVO<CourseDto> pageCourseList(CourseQueryParam queryParam,Long uid) {
        Long startNum = queryParam.getPageSize()*(queryParam.getPageNum()-1);
        Long endNum = queryParam.getPageSize();
        List<CourseDto>  list = signupMapper.getCoursePageList(queryParam.getCourse(),startNum,endNum,uid);
        Integer count = signupMapper.getCoursePageCount(queryParam.getCourse(),uid);
        PageVO<CourseDto> pageVO = new PageVO(list,Long.valueOf(count),queryParam.getPageNum(),queryParam.getPageSize());
        return pageVO;
    }
}
